#region Using

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;

using Gizmox.WebGUI.Common;
using Gizmox.WebGUI.Forms;
using Agresso.Interface.Layer.Domain;
using Agresso.Interface.Layer.Service;

#endregion

namespace Agresso.Interface.Layer.Web
{
    public partial class DADeskAccountForm : Form
    {
        DaDeskAccount m_company;
        DADesk_PDA_Service m_daDeskService;
        UserControlDaDeskAccountMapping m_parent;

        public DADeskAccountForm(DaDeskAccount company, UserControlDaDeskAccountMapping parent)
        {
            InitializeComponent();
            Text = "Update Account";
            m_daDeskService = new DADesk_PDA_Service();
            m_parent = parent;
            m_company = company;
            textBoxAccountCode.Text = m_company.AccountCode;
            textBoxAgressoAccount.Text = m_company.AgrAccountCode;
        }

        private void button1OK_Click(object sender, EventArgs e)
        {
            updateVessel();
            this.Close();
        }

        private void updateVessel()
        {
            m_company.AccountCode = textBoxAccountCode.Text;
            m_company.AgrAccountCode = textBoxAgressoAccount.Text;
            m_daDeskService.UpdateAccount(m_company);
            m_parent.UpdateSelectedItem(m_company);
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void buttonApply_Click(object sender, EventArgs e)
        {
            updateVessel();
            buttonApply.Enabled = false;
        }

        private void DADeskVesselForm_Load(object sender, EventArgs e)
        {
            textBoxAgressoAccount.Focus();
        }

        private void activate_apply(object sender, KeyPressEventArgs e)
        {
            buttonApply.Enabled = true;
        }
    }
}